//Do-file to run models in the pooled data
//Last changed by SAO 250109


capture log close
log using "C:\Userdata\Shared\Dofiles\DoAnalysis\PGS and politics\Replication files\MainResults.log", text replace

clear all

use "E:\ProjData\PGS and politics/STRdata.dta", clear
*use "E:\ProjData\PGS and politics/WLSdata.dta", clear
*use "E:\ProjData\PGS and politics/MTFSdata.dta"
*use "E:\ProjData\PGS and politics/AHdata.dta"
append using "E:\ProjData\PGS and politics/WLSdata.dta"
append using "E:\ProjData\PGS and politics/MTFSdata.dta"
append using "E:\ProjData\PGS and politics/AHdata.dta"

gen samplenum = .
replace samplenum = 1 if sample=="STR"
replace samplenum = 2 if sample=="wls"
replace samplenum = 3 if sample=="mtfs"
replace samplenum = 4 if sample=="ah"

replace Byear = Byear+1900 if sample=="mtfs"

rename EduYears EA

********
*MODELS*
********

**************************
***Sum stats - Table A3***
**************************
preserve
drop if PC1==.
bysort sample: sum Turnout1 Turnout2 TurnoutSelf PolPart MALE Byear
restore


*********************************
***Baseline results - Table A4***
*********************************
quietly {
preserve
local DV = "Turnout1"
*local DV = "Turnout2"
*local DV = "TurnoutSelf"
*local DV = "PolPart"
drop if `DV'==.
drop if PC1==.

noisily display as text "SUM STATS FOR `DV'"
noisily sum `DV'

*BETWEEN-FAMILY - SEPARATE MODELS
foreach name in EA CP EXTRA NEURO RISK ADVENTURE MORNING SRH DEP SWB ACTIVITY {
reg `DV' std`name'_PGI c.MALE##i.Byear PC1-PC10 i.samplenum, cluster(PairID)
noisily display as text ""
noisily display as text ""
noisily display as text "BETWEEN-FAMILY EFFECT OF std`name'_PGI"
noisily lincom std`name'_PGI
gen scoreR2 = e(r2)
reg `DV' c.MALE##i.Byear PC1-PC10 i.samplenum if e(sample), cluster(PairID)
gen noscoreR2 = e(r2)
gen diff = scoreR2 - noscoreR2
noisily display as text ""
noisily display as text "Incremental R2 = " as result diff
drop scoreR2 noscoreR2 diff
}
restore
}


*****************************************
**BENJAMINI-HOCHBERG - BASELINE MODELS***
*****************************************
foreach name in Turnout1 Turnout2 TurnoutSelf PolPart {
preserve
drop if `name'==.
drop if PC1==.
tempfile `name'
save ``name''
restore
}


local DV = "Turnout1"
*local DV = "Turnout2"
*local DV = "TurnoutSelf"
*local DV = "PolPart"


use ``DV'', clear

*BETWEEN-FAMILY - SEPARATE MODELS
local j = 1
gen p = .
gen name = ""

foreach name in CP EXTRA NEURO RISK ADVENTURE MORNING SRH DEP SWB ACTIVITY {
qui: reg `DV' std`name'_PGI c.MALE##i.Byear PC1-PC10 i.samplenum, cluster(PairID)
matrix a = r(table)
replace p = a[4,1] in `j'
replace name = "`name'" in `j'
local j = `j' + 1
}

preserve
keep p name
keep in 1/10
sort p
gen i = _n
gen q90 = 0.10*i/10
gen q90diff = q90 - p
gen q95 = 0.05*i/10
gen q95diff = q95 - p
gen q99 = 0.01*i/10
gen q99diff = q99 - p
noisily display as text ""
noisily display as text ""
noisily display as text "BETWEEN-FAMILY, SEPARATE MODELS (`DV')"
list name p q*diff
restore

drop p name


clear all

use "E:\ProjData\PGS and politics/STRdata.dta", clear
*use "E:\ProjData\PGS and politics/WLSdata.dta", clear
*use "E:\ProjData\PGS and politics/MTFSdata.dta"
*use "E:\ProjData\PGS and politics/AHdata.dta"
append using "E:\ProjData\PGS and politics/WLSdata.dta"
append using "E:\ProjData\PGS and politics/MTFSdata.dta"
append using "E:\ProjData\PGS and politics/AHdata.dta"

gen samplenum = .
replace samplenum = 1 if sample=="STR"
replace samplenum = 2 if sample=="wls"
replace samplenum = 3 if sample=="mtfs"
replace samplenum = 4 if sample=="ah"

replace Byear = Byear+1900 if sample=="mtfs"

rename EduYears EA


************************************
***Mediation analyses - Table A11***
************************************

clear all

use "E:\ProjData\PGS and politics/STRdata.dta", clear
*use "E:\ProjData\PGS and politics/WLSdata.dta", clear
*use "E:\ProjData\PGS and politics/MTFSdata.dta"
*use "E:\ProjData\PGS and politics/AHdata.dta"
append using "E:\ProjData\PGS and politics/WLSdata.dta"
append using "E:\ProjData\PGS and politics/MTFSdata.dta"
append using "E:\ProjData\PGS and politics/AHdata.dta"

gen samplenum = .
replace samplenum = 1 if sample=="STR"
replace samplenum = 2 if sample=="wls"
replace samplenum = 3 if sample=="mtfs"
replace samplenum = 4 if sample=="ah"

replace Byear = Byear+1900 if sample=="mtfs"

rename EduYears EA


quietly {
preserve
drop if PC1==.


*BETWEEN-FAMILY - SEPARATE MODELS
foreach name in CP EXTRA NEURO RISK SRH DEP SWB ACTIVITY {
*foreach name in CP EXTRA NEURO RISK SWB { //MTFS
reg `name' std`name'_PGI c.MALE##i.Byear PC1-PC10 i.samplenum, cluster(PairID)
noisily display as text ""
noisily display as text ""
noisily display as text "BETWEEN-FAMILY EFFECT OF std`name'_PGI"
noisily lincom std`name'_PGI
gen scoreR2 = e(r2)
reg `name' c.MALE##i.Byear PC1-PC10 i.samplenum if e(sample), cluster(PairID)
gen noscoreR2 = e(r2)
gen diff = scoreR2 - noscoreR2
noisily display as text ""
noisily display as text "Incremental R2 = " as result diff
drop scoreR2 noscoreR2 diff
noisily display as text "SUM STATS FOR `name'"
noisily sum `name' if e(sample)
}
restore
}

***Drop young individuals in STR for the EA analysis
drop if Byear>1990 & sample=="STR"
quietly {
preserve
drop if PC1==.


*BETWEEN-FAMILY - SEPARATE MODELS
foreach name in EA {
reg `name' std`name'_PGI c.MALE##i.Byear PC1-PC10 i.samplenum, cluster(PairID)
noisily display as text ""
noisily display as text ""
noisily display as text "BETWEEN-FAMILY EFFECT OF std`name'_PGI"
noisily lincom std`name'_PGI
gen scoreR2 = e(r2)
reg `name' c.MALE##i.Byear PC1-PC10 i.samplenum if e(sample), cluster(PairID)
gen noscoreR2 = e(r2)
gen diff = scoreR2 - noscoreR2
noisily display as text ""
noisily display as text "Incremental R2 = " as result diff
drop scoreR2 noscoreR2 diff
noisily display as text "SUM STATS FOR `name'"
noisily sum `name' if e(sample)
}
restore
}


************************************
***Mediation analyses - Table A12***
************************************
*BETWEEN-FAMILY - SEPARATE MODELS
foreach name in CP EXTRA NEURO RISK SRH DEP SWB ACTIVITY {
preserve
local DV = "Turnout1"
*local DV = "Turnout2"
*local DV = "TurnoutSelf"
*local DV = "PolPart"
drop if `DV'==.
drop if `name'==.
drop if PC1==.

noisily display as text ""
noisily display as text ""
noisily display as text "SUM STATS FOR `DV' and `name'"
noisily sum `DV' `name'

qui reg `DV' std`name'_PGI `name' c.MALE##i.Byear PC1-PC10 i.samplenum, cluster(PairID)
gen b_med = _b[std`name'_PGI]
noisily display as text ""
noisily display as text ""
noisily display as text "BETWEEN-FAMILY EFFECTS OF std`name'_PGI and `name'"
noisily lincom std`name'_PGI
noisily lincom `name'
qui reg `DV' std`name'_PGI c.MALE##i.Byear PC1-PC10 i.samplenum if e(sample), cluster(PairID)
gen b_unmed = _b[std`name'_PGI]
gen change = (b_med-b_unmed)/b_unmed
noisily display as text ""
noisily display as text "BETWEEN-FAMILY EFFECTS OF std`name'_PGI"
noisily lincom std`name'_PGI
sum change
drop b_* change

restore
}



***Drop younger individuals in STR for the EA analysis
foreach name in EA {
preserve
drop if Byear>1990 & sample=="STR"
*local DV = "Turnout1"
*local DV = "Turnout2"
*local DV = "TurnoutSelf"
local DV = "PolPart"
drop if `DV'==.
drop if `name'==.
drop if PC1==.

noisily display as text ""
noisily display as text ""
noisily display as text "SUM STATS FOR `DV' and `name'"
noisily sum `DV' `name'

qui reg `DV' std`name'_PGI `name' c.MALE##i.Byear PC1-PC10 i.samplenum, cluster(PairID)
gen b_med = _b[std`name'_PGI]
noisily display as text ""
noisily display as text ""
noisily display as text "BETWEEN-FAMILY EFFECTS OF std`name'_PGI and `name'"
noisily lincom std`name'_PGI
noisily lincom `name'
qui reg `DV' std`name'_PGI c.MALE##i.Byear PC1-PC10 i.samplenum if e(sample), cluster(PairID)
gen b_unmed = _b[std`name'_PGI]
gen change = (b_med-b_unmed)/b_unmed
noisily display as text ""
noisily display as text "BETWEEN-FAMILY EFFECTS OF std`name'_PGI"
noisily lincom std`name'_PGI
sum change
drop b_* change

restore
}




**************************************
***Confounding analyses - Table A13***
**************************************
*BETWEEN-FAMILY - SEPARATE MODELS
foreach name in CP EXTRA NEURO RISK SRH DEP SWB ACTIVITY {
preserve
*local DV = "Turnout1"
local DV = "Turnout2"
*local DV = "TurnoutSelf"
*local DV = "PolPart"
drop if `DV'==.
drop if `name'==.
drop if PC1==.
drop stdHEIGHT_PGI stdBMI_PGI

qui reg `DV' `name' std* c.MALE##i.Byear PC1-PC10 i.samplenum, cluster(PairID)
gen b_med = _b[`name']
noisily display as text ""
noisily display as text ""
noisily display as text "BETWEEN-FAMILY EFFECTS OF `name'"
noisily lincom `name'
qui reg `DV' `name' c.MALE##i.Byear PC1-PC10 i.samplenum if e(sample), cluster(PairID)
gen b_unmed = _b[`name']
gen change = (b_med-b_unmed)/b_unmed
noisily display as text ""
noisily display as text "BETWEEN-FAMILY EFFECTS OF `name'"
noisily lincom `name'
sum change
drop b_* change

restore
}

***Drop younger individuals in STR for the EA analysis
foreach name in EA {
preserve
drop if Byear>1990 & sample=="STR"
*local DV = "Turnout1"
*local DV = "Turnout2"
*local DV = "TurnoutSelf"
local DV = "PolPart"
drop if `DV'==.
drop if `name'==.
drop if PC1==.
drop stdHEIGHT_PGI stdBMI_PGI

qui reg `DV' `name' std* c.MALE##i.Byear PC1-PC10 i.samplenum, cluster(PairID)
gen b_med = _b[`name']
noisily display as text ""
noisily display as text ""
noisily display as text "BETWEEN-FAMILY EFFECTS OF `name'"
noisily lincom `name'
qui reg `DV' `name' c.MALE##i.Byear PC1-PC10 i.samplenum if e(sample), cluster(PairID)
gen b_unmed = _b[`name']
gen change = (b_med-b_unmed)/b_unmed
noisily display as text ""
noisily display as text "BETWEEN-FAMILY EFFECTS OF `name'"
noisily lincom `name'
sum change
drop b_* change

restore
}








**************************************************
***Between- vs. within-family models - Table A5***
**************************************************
*Keep only DZs and full siblings
drop if BESTZYG==1 | BESTZYG==3
drop if mz==1
drop if FTYPE==1 | FTYPE==5 | FTYPE==6


quietly {
preserve
local DV = "Turnout1"
*local DV = "Turnout2"
*local DV = "TurnoutSelf"
*local DV = "PolPart"
drop if `DV'==.
drop if PC1==.
bysort PairID: gen occ = _N
keep if occ==2
drop occ

noisily display as text "SUM STATS FOR `DV'"
noisily sum `DV'

*BETWEEN-FAMILY - SEPARATE MODELS
foreach name in CP EXTRA NEURO RISK ADVENTURE MORNING SRH DEP SWB ACTIVITY {
reg `DV' std`name'_PGI c.MALE##i.Byear PC1-PC10 i.samplenum, cluster(PairID)
noisily display as text ""
noisily display as text ""
noisily display as text "BETWEEN-FAMILY EFFECT OF std`name'_PGI"
noisily lincom std`name'_PGI
gen scoreR2 = e(r2)
reg `DV' c.MALE##i.Byear PC1-PC10 i.samplenum if e(sample), cluster(PairID)
gen noscoreR2 = e(r2)
gen diff = scoreR2 - noscoreR2
noisily display as text ""
noisily display as text "Incremental R2 = " as result diff
drop scoreR2 noscoreR2 diff
}

*WITHIN-FAMILY - SEPARATE MODELS
xtset PairID

foreach name in CP EXTRA NEURO RISK ADVENTURE MORNING SRH DEP SWB ACTIVITY {
xtreg `DV' std`name'_PGI c.MALE##i.Byear PC1-PC10, fe cluster(PairID)
noisily display as text ""
noisily display as text ""
noisily display as text "WITHIN-FAMILY EFFECT OF `name'"
noisily lincom std`name'_PGI
gen scoreR2 = e(r2)
xtreg `DV' c.MALE##i.Byear PC1-PC10 if e(sample), fe cluster(PairID)
gen noscoreR2 = e(r2)
gen diff = scoreR2 - noscoreR2
noisily display as text ""
noisily display as text "Incremental R2 = " as result diff
drop scoreR2 noscoreR2 diff
}
restore
}


********************************************
**BENJAMINI-HOCHBERG - BETWEEN VS. WITHIN***
********************************************
foreach name in Turnout1 Turnout2 TurnoutSelf PolPart {
preserve
drop if `name'==.
drop if PC1==.
bysort PairID: gen occ = _N
keep if occ==2
drop occ
tempfile `name'
save ``name''
restore
}


local DV = "Turnout1"
*local DV = "Turnout2"
*local DV = "TurnoutSelf"
*local DV = "PolPart"


use ``DV'', clear

*BETWEEN-FAMILY - SEPARATE MODELS
local j = 1
gen p = .
gen name = ""

foreach name in CP EXTRA NEURO RISK ADVENTURE MORNING SRH DEP SWB ACTIVITY {
qui: reg `DV' std`name'_PGI c.MALE##i.Byear PC1-PC10 i.samplenum, cluster(PairID)
matrix a = r(table)
replace p = a[4,1] in `j'
replace name = "`name'" in `j'
local j = `j' + 1
}

preserve
keep p name
keep in 1/10
sort p
gen i = _n
gen q90 = 0.10*i/10
gen q90diff = q90 - p
gen q95 = 0.05*i/10
gen q95diff = q95 - p
gen q99 = 0.01*i/10
gen q99diff = q99 - p
noisily display as text ""
noisily display as text ""
noisily display as text "BETWEEN-FAMILY, SEPARATE MODELS (`DV')"
list name p q*diff
restore

drop p name



***WITHIN-FAMILY - SEPARATE MODELS
xtset PairID
local k = 1
gen p = .
gen name = ""

foreach name in CP EXTRA NEURO RISK ADVENTURE MORNING SRH DEP SWB ACTIVITY {
qui: xtreg `DV' std`name'_PGI c.MALE##i.Byear PC1-PC10, fe cluster(PairID)
matrix c = r(table)
replace p = c[4,1] in `k'
replace name = "`name'" in `k'
local k = `k' + 1
}

preserve
keep p name
keep in 1/10
sort p
gen i = _n
gen q90 = 0.10*i/10
gen q90diff = q90 - p
gen q95 = 0.05*i/10
gen q95diff = q95 - p
gen q99 = 0.01*i/10
gen q99diff = q99 - p
noisily display as text ""
noisily display as text ""
noisily display as text "WITHIN-FAMILY, SEPARATE MODELS (`DV')"
list name p q*diff
restore

drop p name



********************************
***ADDITIONAL APPENDIX MODELS***
********************************

clear all

use "E:\ProjData\PGS and politics/STRdata.dta", clear
*use "E:\ProjData\PGS and politics/WLSdata.dta", clear
*use "E:\ProjData\PGS and politics/MTFSdata.dta"
*use "E:\ProjData\PGS and politics/AHdata.dta"
append using "E:\ProjData\PGS and politics/WLSdata.dta"
append using "E:\ProjData\PGS and politics/MTFSdata.dta"
append using "E:\ProjData\PGS and politics/AHdata.dta"

gen samplenum = .
replace samplenum = 1 if sample=="STR"
replace samplenum = 2 if sample=="wls"
replace samplenum = 3 if sample=="mtfs"
replace samplenum = 4 if sample=="ah"

replace Byear = Byear+1900 if sample=="mtfs"

rename EduYears EA

********************************************************************************
***Baseline results for separate political participation measures - Table A10***
********************************************************************************
quietly {
preserve
local DV = "Contact"
*local DV = "Contribute"
*local DV = "Rally"
drop if `DV'==.
drop if PC1==.

noisily display as text "SUM STATS FOR `DV'"
noisily sum `DV'

*BETWEEN-FAMILY - SEPARATE MODELS
foreach name in EA CP EXTRA NEURO RISK ADVENTURE MORNING SRH DEP SWB ACTIVITY {
reg `DV' std`name'_PGI c.MALE##i.Byear PC1-PC10 i.samplenum, cluster(PairID)
noisily display as text ""
noisily display as text ""
noisily display as text "BETWEEN-FAMILY EFFECT OF std`name'_PGI"
noisily lincom std`name'_PGI
gen scoreR2 = e(r2)
reg `DV' c.MALE##i.Byear PC1-PC10 i.samplenum if e(sample), cluster(PairID)
gen noscoreR2 = e(r2)
gen diff = scoreR2 - noscoreR2
noisily display as text ""
noisily display as text "Incremental R2 = " as result diff
drop scoreR2 noscoreR2 diff
}
restore
}



***********************************
**BENJAMINI-HOCHBERG - Table A10***
***********************************
foreach name in Contact Contribute Rally {
preserve
drop if `name'==.
drop if PC1==.
tempfile `name'
save ``name''
restore
}


local DV = "Contact"
*local DV = "Contribute"
*local DV = "Rally"


use ``DV'', clear

*BETWEEN-FAMILY - SEPARATE MODELS
local j = 1
gen p = .
gen name = ""

foreach name in CP EXTRA NEURO RISK ADVENTURE MORNING SRH DEP SWB ACTIVITY {
qui: reg `DV' std`name'_PGI c.MALE##i.Byear PC1-PC10 i.samplenum, cluster(PairID)
matrix a = r(table)
replace p = a[4,1] in `j'
replace name = "`name'" in `j'
local j = `j' + 1
}

preserve
keep p name
keep in 1/10
sort p
gen i = _n
gen q90 = 0.10*i/10
gen q90diff = q90 - p
gen q95 = 0.05*i/10
gen q95diff = q95 - p
gen q99 = 0.01*i/10
gen q99diff = q99 - p
noisily display as text ""
noisily display as text ""
noisily display as text "BETWEEN-FAMILY, SEPARATE MODELS (`DV')"
list name p q*diff
restore

drop p name



*****************************************************************************************
***TEST FOR EQUALITY OF PGI COEFFICIENTS USING SUEST MODELS ACROSS OUTCOMES - Table 10***
*****************************************************************************************
clear all

use "E:\ProjData\PGS and politics/STRdata.dta", clear
*use "E:\ProjData\PGS and politics/WLSdata.dta", clear
*use "E:\ProjData\PGS and politics/MTFSdata.dta"
*use "E:\ProjData\PGS and politics/AHdata.dta"
append using "E:\ProjData\PGS and politics/WLSdata.dta"
append using "E:\ProjData\PGS and politics/MTFSdata.dta"
append using "E:\ProjData\PGS and politics/AHdata.dta"

gen samplenum = .
replace samplenum = 1 if sample=="STR"
replace samplenum = 2 if sample=="wls"
replace samplenum = 3 if sample=="mtfs"
replace samplenum = 4 if sample=="ah"

replace Byear = Byear+1900 if sample=="mtfs"

rename EduYears EA

quietly {
preserve
drop if PolPart==.
drop if PC1==.

*BETWEEN-FAMILY - SEPARATE MODELS
foreach name in EA CP EXTRA NEURO RISK ADVENTURE MORNING SRH DEP SWB ACTIVITY {
reg Contact std`name'_PGI c.MALE##i.Byear PC1-PC10 i.samplenum
est sto Contact
reg Contribute std`name'_PGI c.MALE##i.Byear PC1-PC10 i.samplenum
est sto Contribute
reg Rally std`name'_PGI c.MALE##i.Byear PC1-PC10 i.samplenum
est sto Rally
suest Contact Contribute Rally, vce(cluster PairID)
noisily testnl [Contact_mean]std`name'_PGI = [Contribute_mean]std`name'_PGI = [Rally_mean]std`name'_PGI

}
restore
}



***************************************************************
***Separate baseline models for each subsample - Tables A6-9***
***************************************************************

***Baseline results
quietly {
preserve
*local DV = "Turnout1"
*local DV = "Turnout2"
*local DV = "TurnoutSelf"
local DV = "PolPart"
drop if `DV'==.
drop if PC1==.

noisily display as text "SUM STATS FOR `DV'"
noisily sum `DV'

*BETWEEN-FAMILY - SEPARATE MODELS
foreach name in EA CP EXTRA NEURO RISK ADVENTURE MORNING SRH DEP SWB ACTIVITY {
reg `DV' std`name'_PGI c.MALE##i.Byear PC1-PC10 i.samplenum, cluster(PairID)
noisily display as text ""
noisily display as text ""
noisily display as text "BETWEEN-FAMILY EFFECT OF std`name'_PGI"
noisily lincom std`name'_PGI
gen scoreR2 = e(r2)
reg `DV' c.MALE##i.Byear PC1-PC10 i.samplenum if e(sample), cluster(PairID)
gen noscoreR2 = e(r2)
gen diff = scoreR2 - noscoreR2
noisily display as text ""
noisily display as text "Incremental R2 = " as result diff
drop scoreR2 noscoreR2 diff
}
restore
}


*************************************
**BENJAMINI-HOCHBERG - Tables A6-9***
*************************************
foreach name in Turnout1 Turnout2 PolPart { //STR
*foreach name in Turnout1 Turnout2 { //WLS
*foreach name in Turnout1 Turnout2 TurnoutSelf { //MTFS
*foreach name in TurnoutSelf PolPart { //AH
preserve
drop if `name'==.
drop if PC1==.
tempfile `name'
save ``name''
restore
}


*local DV = "Turnout1"
*local DV = "Turnout2"
*local DV = "TurnoutSelf"
local DV = "PolPart"


use ``DV'', clear

*BETWEEN-FAMILY - SEPARATE MODELS
local j = 1
gen p = .
gen name = ""

foreach name in CP EXTRA NEURO RISK ADVENTURE MORNING SRH DEP SWB ACTIVITY {
qui: reg `DV' std`name'_PGI c.MALE##i.Byear PC1-PC10 i.samplenum, cluster(PairID)
matrix a = r(table)
replace p = a[4,1] in `j'
replace name = "`name'" in `j'
local j = `j' + 1
}

preserve
keep p name
keep in 1/10
sort p
gen i = _n
gen q90 = 0.10*i/10
gen q90diff = q90 - p
gen q95 = 0.05*i/10
gen q95diff = q95 - p
gen q99 = 0.01*i/10
gen q99diff = q99 - p
noisily display as text ""
noisily display as text ""
noisily display as text "BETWEEN-FAMILY, SEPARATE MODELS (`DV')"
list name p q*diff
restore

drop p name



******************************************************************************
***TEST FOR SIGNIFICANT CROSS-SAMPLE HETEROGENOUS PGI EFFECTS - Tables A6-9***
******************************************************************************
clear all

use "E:\ProjData\PGS and politics/STRdata.dta", clear
*use "E:\ProjData\PGS and politics/WLSdata.dta", clear
*use "E:\ProjData\PGS and politics/MTFSdata.dta"
*use "E:\ProjData\PGS and politics/AHdata.dta"
append using "E:\ProjData\PGS and politics/WLSdata.dta"
append using "E:\ProjData\PGS and politics/MTFSdata.dta"
append using "E:\ProjData\PGS and politics/AHdata.dta"

gen samplenum = .
replace samplenum = 1 if sample=="STR"
replace samplenum = 2 if sample=="wls"
replace samplenum = 3 if sample=="mtfs"
replace samplenum = 4 if sample=="ah"

replace Byear = Byear+1900 if sample=="mtfs"

rename EduYears EA

***Baseline results
quietly {
preserve
local DV = "Turnout1"
*local DV = "Turnout2"
*local DV = "TurnoutSelf"
*local DV = "PolPart"
drop if `DV'==.
drop if PC1==.

noisily display as text "SUM STATS FOR `DV'"
noisily sum `DV'

*BETWEEN-FAMILY - TEST FOR CROSS-SAMPLE HETEROGENOUS PGI EFFECTS
foreach name in EA CP EXTRA NEURO RISK ADVENTURE MORNING SRH DEP SWB ACTIVITY {
reg `DV' c.std`name'_PGI##i.samplenum c.MALE##i.Byear PC1-PC10, cluster(PairID)
noisily display as text ""
noisily display as text ""
noisily display as text "BETWEEN-FAMILY EFFECT OF std`name'_PGI"

*Firt- and second order voting
noisily test 2.samplenum#c.std`name'_PGI 3.samplenum#c.std`name'_PGI

*Self-rated voting and the participation index
*noisily test 4.samplenum#c.std`name'_PGI
}
restore
}

log close

